package org.itsolutions.javaBackup.gui.web.admin;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.itsolutions.javaBackup.gui.web.common.ApplicationDataHolder;
import org.itsolutions.javaBackup.gui.web.common.EGUIApplication;

import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;

/**
 * 
 * @author Tomas Fecko
 */
@Singleton
public class PageFilterAdmin implements Filter {

    private final Injector mInjector;
    
    /**
     * 
     * @param pInjector injector
     */
    @Inject PageFilterAdmin(Injector pInjector) {
		mInjector = pInjector;
	}

	@Override
    public final void init(FilterConfig pFilterConfig) throws ServletException {
    }

    @Override
    public final void doFilter(ServletRequest pRequest, ServletResponse pResponse, FilterChain pChain) throws IOException, ServletException {
        mInjector.getInstance(ApplicationDataHolder.class).setApplicationEnum(EGUIApplication.ADMIN);
        pChain.doFilter(pRequest, pResponse);
    }

    @Override
    public void destroy() {
    }
}




